import request from './request';

// 用户管理API接口

// 获取用户列表
export function getUserList(params: any) {
  return request({
    url: '/api/user/list',
    method: 'get',
    params: {
      pageNum: params.page || 1,
      pageSize: params.size || 10,
      username: params.keyword,
      nickname: params.keyword,
      phone: params.keyword,
      email: params.keyword
    },
  });
}

// 获取所有用户
export function getAllUsers() {
  return request({
    url: '/api/user/all',
    method: 'get',
  });
}

// 创建用户
export function createUser(data: any) {
  return request({
    url: '/api/user/register',
    method: 'post',
    data,
  });
}

// 更新用户信息
export function updateUser(data: any) {
  return request({
    url: '/api/user/update',
    method: 'put',
    data,
  });
}

// 删除用户
export function deleteUser(userId: string | number) {
  return request({
    url: `/api/user/${userId}`,
    method: 'delete',
  });
}

// 更新用户状态
export function updateUserStatus(userId: string | number, status: number) {
  return request({
    url: `/api/user/status/${userId}`,
    method: 'put',
    data: { status },
  });
}

// 重置用户密码
export function resetUserPassword(userId: string | number, newPassword: string) {
  return request({
    url: `/api/user/reset-password/${userId}`,
    method: 'put',
    data: { password: newPassword },
  });
}

// 获取用户积分信息
export function getUserPoints(userId: string | number) {
  return request({
    url: `/api/user/points/${userId}`,
    method: 'get',
  });
}